﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DebugLog.cs" company="XamlNinja">
//   2011 Richard Griffin and Ollie Riches
// </copyright>
// <summary>
//   Interface defining the logging API.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.Logging
{
    using System;
    using System.Diagnostics;

    public sealed class DebugLog : ILog
    {
        private const string DateFormat = "dd-MM-yyyy HH:mm:ss.fff";

        public ILog Write(string message)
        {
            Debug.WriteLine(string.Format("{0} - {1}", DateTime.Now.ToString(DateFormat), message));

            return this;
        }

        public ILog Write(string message, params object[] args)
        {
            var messageWithParameters = string.Format(message, args);
            Debug.WriteLine(string.Format("{0} - {1}", DateTime.Now.ToString(DateFormat), messageWithParameters));

            return this;
        }

        public ILog Write(string message, Exception exception)
        {
            var date = DateTime.Now.ToString(DateFormat);

            Debug.WriteLine(string.Format("{0} - {1}", date, message));
            Debug.WriteLine((string.Format("{0} - Exception '{1}'", date, exception)));

            return this;
        }

        public ILog WriteDiagnostics()
        {
            return this;
        }
    }
}